package frontend.datashow.historyShow;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.Locale;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jdesktop.swingx.JXPanel;

//import com.eltima.components.ui.DatePicker;

import frontend.bean.BasicCombox;
import frontend.bean.ComboBoxItem;

public class QueryPanel extends JXPanel implements ActionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5349427603765545634L;

	
	private JLabel collectPointLbl = new JLabel("采集点：");
	private JLabel collectItemLbl  = new JLabel("　　采集项目：");
	private JLabel queryTimeLbl = new JLabel("　　查询时间：");
	private JLabel periodTimeLbl = new JLabel("间隔时间：");
	private JLabel minuteLbl = new JLabel("（分钟）");
	
//	private DatePicker datepickStart;
//	private DatePicker datapickEnd;
	private static final String DefaultFormat = "yyyy-MM-dd HH:mm:ss";
	private Date date=new Date();
	private Font font=new Font("Times New Roman", Font.BOLD, 14);
	private Dimension dimension=new Dimension(177,24);
	private int[] hilightDays={1,3,5,7};
	private int[] disabledDays={4,6,5,9};
	private JLabel separatorLbl = new JLabel("　～ 　");
	
	
	
	private JButton queryBtn = new JButton("查询");
	private JButton resetBtn = new JButton("清除");
	
	private JXPanel queryCommandPanel = new JXPanel();
	private JPanel queryTimePanel = new JPanel();
	
	public static int BUTTON_LENGTH = 10;
	
	private BasicCombox collectPoint;
	private BasicCombox collectItem;

	public QueryPanel() {
		initCollectPoint();
		initCollectItem();
		init();
	}

	private void init() {
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		int indexX = 0;
		int indexY = 0;
		gbc.gridx = indexX++;
		gbc.gridy = indexY++;
		add(collectPointLbl, gbc);
		gbc.gridx = indexX++;
		add(collectPoint, gbc);
		
		gbc.gridx = indexX++;
		add(collectItemLbl, gbc);
		gbc.gridx = indexX++;
		add(collectItem, gbc);
		
		initQueryTimePanel();
		
		
		gbc.gridx = indexX++;
		add(queryTimePanel, gbc);
		
//		initQueryCommandPanel();
	}
	
	private void initQueryCommandPanel() {
		queryCommandPanel.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.anchor = GridBagConstraints.LINE_END;
		queryCommandPanel.add(queryBtn, gbc);
		gbc.gridx = 1;
		queryCommandPanel.add(resetBtn, gbc);
		
	}
	
	private void initQueryTimePanel() {
		
//		datepickStart = new DatePicker(date,DefaultFormat,font,dimension);//自定义参数值
//		datepickStart.setHightlightdays(hilightDays, Color.red);//设置一个月份中需要高亮显示的日子
//		datepickStart.setDisableddays(disabledDays);//设置一个月份中不需要的日子，呈灰色显示
//		datepickStart.setLocale(Locale.CHINA);//设置国家
//		datepickStart.setTimePanleVisible(true);//设置时钟面板可见
//		Dimension d = datepickStart.getPreferredSize();
//		datepickStart.setPreferredSize(new Dimension(d.width - 30, d.height));
//		datapickEnd = new DatePicker(date,DefaultFormat,font,dimension);//自定义参数值
//		datapickEnd.setHightlightdays(hilightDays, Color.red);//设置一个月份中需要高亮显示的日子
//		datapickEnd.setDisableddays(disabledDays);//设置一个月份中不需要的日子，呈灰色显示
//		datapickEnd.setLocale(Locale.CHINA);//设置国家
//		datapickEnd.setTimePanleVisible(true);//设置时钟面板可见
//		d = datapickEnd.getPreferredSize();
//		datapickEnd.setPreferredSize(new Dimension(d.width - 30, d.height));
//		
		
		queryTimePanel.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		queryTimePanel.add(queryTimeLbl, gbc);
		gbc.gridx = 1;
//		queryTimePanel.add(datepickStart, gbc);
		gbc.gridx = 2;
		queryTimePanel.add(separatorLbl, gbc);
		gbc.gridx = 3;
//		queryTimePanel.add(datapickEnd, gbc);
	}

	public void actionPerformed(ActionEvent e) {

		//***************************************
		
		
		//**************************************
			
	}
	
	private void initCollectPoint() {
		collectPoint = new BasicCombox();
		ComboBoxItem item = new ComboBoxItem("电池组A", "1",
				ComboBoxItem.CBX_ITEM_DATA);
		collectPoint.addItem(item);
		item = new ComboBoxItem("电池组B", "2", ComboBoxItem.CBX_ITEM_DATA);
		collectPoint.addItem(item);
		item = new ComboBoxItem("电池组C", "3", ComboBoxItem.CBX_ITEM_DATA);
		collectPoint.addItem(item);
		item = new ComboBoxItem("电池组D", "4", ComboBoxItem.CBX_ITEM_DATA);
		collectPoint.addItem(item);
	}

	private void initCollectItem() {
		collectItem = new BasicCombox();
		ComboBoxItem item = new ComboBoxItem("电压", "1",
				ComboBoxItem.CBX_ITEM_DATA);
		collectItem.addItem(item);
		item = new ComboBoxItem("电流", "2", ComboBoxItem.CBX_ITEM_DATA);
		collectItem.addItem(item);
		item = new ComboBoxItem("电压C", "3", ComboBoxItem.CBX_ITEM_DATA);
		collectItem.addItem(item);
		item = new ComboBoxItem("电流D", "4", ComboBoxItem.CBX_ITEM_DATA);
		collectItem.addItem(item);
	}
}
